﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace Spider
{
    public partial class DataF : Form
    {

        public DataF()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            string query = "select * from detail";
            var rows = SQLHelper.ExecuteDataset(query).Tables[0].Rows;

            foreach (DataRow row in rows)
            {
                string insert1 = "insert into userinfo(login_name,pwd,level,state) values('" + row["name"] + "','111111',2,0)";
                if (MySqlHelper.ExecuteNonQuery(insert1) > 0)
                {
                    string quid = "SELECT LAST_INSERT_ID()";
                    string uid = MySqlHelper.ExecuteDataSet(quid).Tables[0].Rows[0][0].ToString();

                    string insert2 = string.Format(@"
insert into userdetail(uid,name,sex,age,height,weight,province,qq,content,state,face,job,education,stance,marriage)
 values('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}','{12}','{13}','{14}')",
uid, row["name"], row["sex"], row["age"], row["height"], row["weight"], row["province"], row["qq"], row["content"], 0,
row["face"], row["job"], row["education"], row["stance"], row["marriage"]);

                    MySqlHelper.ExecuteNonQuery(insert2);
                }


            }

            MessageBox.Show("OKKKKKKKKKKKK");
        }
    }
}
